var e = require,
    t = module,
    n = exports;

Object.defineProperty(n, "__esModule", {
    value: !0
});

var o = e("GameData"),
    i = e("Global"),
    a = e("UIManager"),
    r = function() {
        function e() {
            this.pre = "default", this.privacy = null;
        }
        return e.getInstance = function() {
            return this._manager || (this._manager = new e()), this._manager;
        }, e.prototype.request = function(e) {
            (GA.isPlatform(GA.Platform.Kwaigame) ? ks : GA).request(e);
        }, e.prototype.sentLog = function(e, s, t, i) {
            this.sentLogs([{
                eventId: e,
                detail: t ? JSON.stringify(t) : "",
                extraNum: s || 0
            }], i);
        }, e.prototype.sentLogs = function(e, s) {
            return;
            this.request({
                url: GA.Urls.SaveLog,
                data: {
                    appid: GA.Info.appId,
                    uuid: GA.Info.openId,
                    list: e,
                    channel: GA.Info.channelId
                },
                method: "POST",
                success: function() {
                    try {
                        s();
                    } catch (e) {}
                }
            });
        }, e.prototype.reqLogin = function(t) {
            var o = this;
            GA.Info.isPreview ? t.success && t.success() : this.request({
                url: i.G.serverUrl + "default/login/reqLogin",
                data: {
                    openid: GA.Info.openId,
                    channel: GA.Info.channelId,
                    nickname: GA.Info.nickname,
                    headicon: GA.Info.avatar
                },
                method: "POST",
                success: function(e) {
                    var s;
                    if (console.log("reqLogin success", JSON.stringify(e)), 0 == e.data.code) GA.setUserId(e.data.data.userId),
                        i.G.timestamp = e.data.data.timestamp, i.G.videoReward = e.data.data.videoReward,
                        i.G.localTime = Date.now(), t.success && t.success(e);
                    else if (i.G.isNative()) {
                        try {
                            a.default.getInstance().showToast({
                                str: "网路连接异常\n请检查网络",
                                delay: 2
                            });
                        } catch (e) {}
                        setTimeout(function() {
                            o.reqLogin(t);
                        }, 5e3);
                    } else null === (e = null === (s = GA.PA) || void 0 === s ? void 0 : s.showModal) || void 0 === e || e.call(s, {
                        title: "连接失败",
                        content: "网络连接失败，请点击重试",
                        success: function(e) {
                            e.confirm && o.reqLogin(t);
                        }
                    });
                },
                fail: function(e) {
                    var s;
                    if (console.log("reqLogin fail", e), i.G.isNative()) {
                        try {
                            a.default.getInstance().showToast({
                                str: "网路连接异常\n请检查网络",
                                delay: 2
                            });
                        } catch (e) {}
                        setTimeout(function() {
                            o.reqLogin(t);
                        }, 5e3);
                    } else null === (e = null === (s = GA.PA) || void 0 === s ? void 0 : s.showModal) || void 0 === e || e.call(s, {
                        title: "连接失败",
                        content: "网络连接失败，请点击重试",
                        success: function(e) {
                            e.confirm && o.reqLogin(t);
                        }
                    });
                }
            });
        }, e.prototype.reqConfig = function(t) {
            t.success && t.success(JSON.parse(`{ "code": 0, "msg": "success", "data": [] }`));

            return;
            var o = this;
            GA.isPlatform(GA.Platform.Kwaigame) ? this.request({
                url: i.G.serverUrl + "default/lobbyV2/reqConfig",
                header: {
                    "content-type": "application/json;charset=UTF-8",
                    appid: GA.Info.appId
                },
                data: {
                    param: []
                },
                method: "POST",
                dataType: "json",
                responseType: "text",
                success: function(e) {
                    t.success && t.success(e);
                },
                fail: function() {
                    var e, s;
                    if (i.G.isNative()) {
                        try {
                            a.default.getInstance().showToast({
                                str: "网路连接异常\n请检查网络",
                                delay: 2
                            });
                        } catch (e) {}
                        setTimeout(function() {
                            o.reqConfig(t);
                        }, 5e3);
                    } else null === (s = null === (e = GA.PA) || void 0 === e ? void 0 : e.showModal) || void 0 === s || s.call(e, {
                        title: "连接失败",
                        content: "网络连接失败，请点击重试",
                        success: function(e) {
                            e.confirm && o.reqConfig(t);
                        }
                    });
                }
            }) : this.request({
                url: i.G.serverUrl + "default/lobby/reqConfig",
                data: {
                    param: []
                },
                method: "POST",
                success: function(e) {
                    t.success && t.success(e);
                },
                fail: function() {
                    var e, s;
                    if (i.G.isNative()) {
                        try {
                            a.default.getInstance().showToast({
                                str: "网路连接异常\n请检查网络",
                                delay: 2
                            });
                        } catch (e) {}
                        setTimeout(function() {
                            o.reqConfig(t);
                        }, 5e3);
                    } else null === (s = null === (e = GA.PA) || void 0 === e ? void 0 : e.showModal) || void 0 === s || s.call(e, {
                        title: "连接失败",
                        content: "网络连接失败，请点击重试",
                        success: function(e) {
                            e.confirm && o.reqConfig(t);
                        }
                    });
                }
            });
        }, e.prototype.reqSaveUser = function(s) {
            s && s.data && null != s.data.userId && this.request({
                url: i.G.serverUrl + "default/game/reqSaveUser",
                data: s.data,
                method: "POST",
                success: function(e) {
                    40 == e.data.code ? GA.PA.showModal({
                        title: "登录过期",
                        content: "你已在其它平台登录",
                        showCancel: !1,
                        success: function() {
                            GA.PA.exitMiniProgram();
                        }
                    }) : s.success && s.success(e);
                }
            });
        }, e.prototype.reqGetUser = function(s) {
            null != GA.Info.uid && this.request({
                url: i.G.serverUrl + "default/game/reqGetUser",
                data: {
                    userId: GA.Info.uid
                },
                method: "POST",
                success: function(e) {
                    console.log("reqGetUser", e), s.success && s.success(e);
                }
            });
        }, e.prototype.reqRank = function(s) {
            null != GA.Info.uid && this.request({
                url: i.G.serverUrl + "default/lobby/reqRank",
                data: {
                    userId: GA.Info.uid
                },
                method: "POST",
                success: function(e) {
                    s.success && s.success(e);
                }
            });
        }, e.prototype.saveRank = function(s) {
            null != GA.Info.uid && this.request({
                url: i.G.serverUrl + "default/lobby/saveRank",
                data: s.data,
                method: "POST",
                success: function(e) {
                    s.success && s.success(e);
                }
            });
        }, e.prototype.reqMatchRank = function(s) {
            null != GA.Info.uid && this.request({
                url: i.G.serverUrl + "default/wjycjRank/reqMatchRank",
                data: {
                    userId: GA.Info.uid
                },
                method: "POST",
                success: function(e) {
                    s.success && s.success(e);
                }
            });
        }, e.prototype.saveMatchRank = function(s) {
            null != GA.Info.uid && this.request({
                url: i.G.serverUrl + "default/matchRank/saveRank",
                data: {
                    userId: GA.Info.uid,
                    score: s.score,
                    needHeadIcon: s.needHeadIcon,
                    nickname: o.GD.playerData.nickname,
                    headicon: o.GD.playerData.icon
                },
                method: "POST",
                success: function(e) {
                    s.success && s.success(e);
                }
            });
        }, e.prototype.getSomeRobots = function(s) {
            var e = this;
            this.request({
                url: i.G.serverUrl + "game/extra/getSomeRobots",
                data: {
                    limit: s.limit
                },
                method: "POST",
                success: function(e) {
                    s.success && s.success(e);
                },
                fail: function() {
                    try {
                        a.default.getInstance().showToast({
                            str: "网路连接异常\n请检查网络",
                            delay: 2
                        });
                    } catch (e) {}
                    setTimeout(function() {
                        e.getSomeRobots(s);
                    }, 5e3);
                }
            });
        }, e.prototype.getSomeIcons = function(s) {
            this.request({
                url: i.G.serverUrl + "game/extra/getSomeIcons",
                data: {
                    limit: s.limit
                },
                method: "POST",
                success: function(e) {
                    s.success && s.success(e);
                }
            });
        }, e.prototype.getRobotList = function(s) {
            var e = this;
            this.request({
                url: i.G.serverUrl + this.pre + "/extraWjycj/getRobotList",
                data: {
                    grade: s.grade,
                    weapon: s.weapon,
                    skin: s.skin,
                    streak: s.streak,
                    robotNum: s.robotNum
                },
                method: "POST",
                success: function(e) {
                    
                    s.success && s.success(e);
                    console.log(e,"e")
                },
                fail: function() {
                    try {
                        // a.default.getInstance().showToast({
                        //     str: "网路连接异常\n请检查网络",
                        //     delay: 2
                        // });
                    } catch (e) {}
                    setTimeout(function() {
                    s.success && s.success(
                        {data:{
                            nickname:"0",
                            nickname:"1",
                            nickname:"222",
                        }}
                    );

                        e.getRobotList(s);
                    }, 5e3);
                }
            });
        }, e.prototype.getMedicalConfig = function(s) {
            this.request({
                url: i.G.serverUrl + this.pre + "/extraWjycj/getMedicalConfig",
                method: "POST",
                success: function(e) {
                    s.success && s.success(e);
                }
            });
        }, e.prototype.subscribe = function(s) {
            this.request({
                url: i.G.serverUrl + this.pre + "/msg/subscribe",
                data: {
                    openid: GA.Info.openId,
                    subscribe: s.subscribe,
                    tplIds: s.tplIds
                },
                method: "POST",
                success: function(e) {
                    s.success && s.success(e);
                }
            });
        }, e.prototype.getSubTplId = function(s) {
            this.request({
                url: i.G.serverUrl + this.pre + "/msg/getSubTplId",
                data: {
                    openid: GA.Info.openId
                },
                method: "POST",
                success: function(e) {
                    s.success && s.success(e);
                }
            });
        }, e.prototype.reqAuth = function(s) {
            GA.Info.uid && this.request({
                url: i.G.serverUrl + this.pre + "/user/auth",
                data: {
                    userId: GA.Info.uid,
                    name: s.name,
                    idcard: s.idcard
                },
                method: "POST",
                success: function(e) {
                    s.success && s.success(e);
                }
            });
        }, e.prototype.reqGetUserAuth = function(s) {
            GA.Info.uid && this.request({
                url: i.G.serverUrl + this.pre + "/user/getUserAuth",
                data: {
                    userId: GA.Info.uid
                },
                method: "POST",
                success: function(e) {
                    s.success && s.success(e);
                }
            });
        }, e.prototype.checkGiftCode = function(s) {
            var e, t;
            GA.Info.uid && s.giftCode && (e = i.G.timestamp + Date.now() - i.G.localTime, t = i.G.getUuid(),
                (t = {
                    userId: GA.Info.uid,
                    giftCode: s.giftCode,
                    timestamp: e,
                    nonce: t,
                    sign: null
                }).sign = i.G.getSignTemp(t), this.request({
                    url: i.G.serverUrl + this.pre + "/wjycjFun/checkGiftCode",
                    data: t,
                    method: "POST",
                    success: function(e) {
                        s.success && s.success(e);
                    }
                }));
        }, e.prototype.giftCode = function(s) {
            var e, t;
            GA.Info.uid && s.giftCode && (e = i.G.timestamp + Date.now() - i.G.localTime, t = i.G.getUuid(),
                (t = {
                    userId: GA.Info.uid,
                    giftCode: s.giftCode,
                    timestamp: e,
                    nonce: t,
                    sign: null
                }).sign = i.G.getSignTemp(t), this.request({
                    url: i.G.serverUrl + this.pre + "/wjycjFun/giftCode",
                    data: t,
                    method: "POST",
                    success: function(e) {
                        s.success && s.success(e);
                    }
                }));
        }, e.prototype.getCity = function(s) {
            return;
            this.request({
                url: i.G.serverUrl + this.pre + "/ip/getCity",
                method: "POST",
                success: function(e) {
                    s.success && s.success(e);
                }
            });
        }, e.prototype.getCoverUrlsByVideoIds = function(s) {
            this.request({
                url: i.G.serverUrl + this.pre + "/tt/getCoverUrlsByVideoIds",
                data: {
                    aliasIds: s.aliasIds
                },
                method: "POST",
                success: function(e) {
                    s.success && s.success(e);
                }
            });
        }, e.prototype.getTopVideoIdsByTime = function(s) {
            this.request({
                url: i.G.serverUrl + this.pre + "/tt/getTopVideoIdsByTime?numberOfTop=" + s.numberOfTop,
                method: "GET",
                success: function(e) {
                    s.success && s.success(e);
                }
            });
        }, e.prototype.getTopVideoIdsByLike = function(s) {
            this.request({
                url: i.G.serverUrl + this.pre + "/tt/getTopVideoIdsByLike?numberOfTop=" + s.numberOfTop,
                method: "GET",
                success: function(e) {
                    s.success && s.success(e);
                }
            });
        }, e.prototype.saveVideoId = function(s) {
            this.request({
                url: i.G.serverUrl + this.pre + "/tt/saveVideoId",
                data: {
                    aliasId: s.aliasId,
                    openid: GA.Info.openId
                },
                method: "POST",
                success: function(e) {
                    s.success && s.success(e);
                }
            });
        }, e.prototype.getVideoId = function(s) {
            this.request({
                url: i.G.serverUrl + this.pre + "/tt/getVideoId",
                data: {
                    openid: GA.Info.openId
                },
                method: "POST",
                success: function(e) {
                    s.success && s.success(e);
                }
            });
        }, e.prototype.getVideoReward = function(s) {
            this.request({
                url: i.G.serverUrl + this.pre + "/tt/getVideoReward",
                data: {
                    openid: GA.Info.openId
                },
                method: "POST",
                success: function(e) {
                    s.success && s.success(e);
                }
            });
        }, e.prototype.sentEvent = function(s) {
            return;
            i.G.launchOptions && i.G.launchOptions.query && i.G.launchOptions.query.clickid && (GA.PA && GA.PA.reportAnalytics("ad_params", {
                adid: i.G.launchOptions.query.adid,
                creativeid: i.G.launchOptions.query.creativeid,
                creativetype: i.G.launchOptions.query.creativetype,
                clickid: i.G.launchOptions.query.clickid,
                event_type: s.event_type
            }), this.request({
                url: "https://ad.toutiao.com/track/activate/?callback=" + i.G.launchOptions.query.clickid + "&event_type=" + s.event_type,
                method: "GET",
                success: function(e) {
                    s.success && s.success(e);
                }
            }));
        }, e.prototype.getLuckDrawConfig = function(s) {

            s.success && s.success(JSON.parse(`{"code":6,"msg":"签名错误","data":-1}`));
            return;

            // var e = {
            //     userId: GA.Info.uid,
            //     drawType: s.drawType
            // };
            // this.request({
            //     url: i.G.serverUrl + this.pre + "/wjycjFun/getLuckDrawConfig",
            //     data: i.G.genSignData(e),
            //     method: "POST",
            //     success: function(e) {
            //         s.success && s.success(e);
            //     }
            // });
        }, e.prototype.luckDraw = function(s) {
            return;

            var e = {
                userId: GA.Info.uid,
                drawType: s.drawType
            };
            this.request({
                url: i.G.serverUrl + this.pre + "/wjycjFun/luckDraw",
                data: i.G.genSignData(e),
                method: "POST",
                success: function(e) {
                    s.success && s.success(e);
                }
            });
        }, e.prototype.lotteryGoldGun = function(s) {
            return;
            var e = {
                openid: GA.Info.openId
            };
            this.request({
                url: i.G.serverUrl + this.pre + "/wjycjqqHb/lotteryGoldGun",
                data: i.G.genSignData(e),
                method: "POST",
                success: function(e) {
                    s.success && s.success(e);
                }
            });
        }, e.prototype.redirectUnite = function(s) {
            return;
            this.request({
                url: i.G.serverUrl + "xyx/basic/redirectUnite",
                data: {
                    Appid: GA.Info.appId,
                    Type: s.Type,
                    IsIOS: i.G.isIOS
                },
                method: "POST",
                success: function(e) {
                    s.success && s.success(e);
                }
            });
        }, e.prototype.redirect = function(s) {
            return;
            this.request({
                url: i.G.serverUrl + "xyx/basic/redirect",
                data: {
                    Appid: GA.Info.appId,
                    Type: s.Type,
                    CurrentAppid: s.CurrentAppid,
                    CurrentPath: s.CurrentPath,
                    IsIOS: i.G.isIOS
                },
                method: "POST",
                success: function(e) {
                    s.success && s.success(e);
                }
            });
        }, e.prototype.redirectPoll = function(s) {
            return;
            this.request({
                url: i.G.serverUrl + "xyx/basic/redirectPoll",
                data: {
                    Appid: GA.Info.appId,
                    Type: s.Type,
                    IsIOS: i.G.isIOS
                },
                method: "POST",
                success: function(e) {
                    console.log(e), s.success && s.success(e);
                }
            });
        }, e.prototype.pushEvent = function(s) {
            return;
            var e, t = this;
            GA.Info.openId && "" != GA.Info.openId && (e = {
                    eventId: s.eventId
                }, s.detail && (e.detail = s.detail), cc.sys.platform == cc.sys.IPAD ? e.detail["设备"] = "iPad" : cc.sys.platform == cc.sys.IPHONE && (e.detail["设备"] = "iPhone"),
                s.extraNum && (e.extraNum = s.extraNum));
        }, e._manager = null, e;
    }();

n.default = r;